﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebSysCore;

namespace HSchSchedule.UC
{
    public partial class NewestPage : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            List<New> lst = DataBase.GetAllNews();

            rptNews.DataSource = lst;
            rptNews.DataBind();
        }

        protected void rptNews_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                New enNews = (New)e.Item.DataItem;

                HyperLink hplTitle = (HyperLink)e.Item.FindControl("hplTitle");
                hplTitle.Text = enNews.Title;
                hplTitle.NavigateUrl="~/BackendPage/NewsDetail.aspx?NewsID="+enNews.NewsID;
            }
        }

    }
}